#!/usr/bin/env python

import json
import sys
import numcompare
from multiprocessing import Pool

def main():
    enindex = json.load(open('../enwiki.json'))
    enarticles = enindex['articles']
    frindex = json.load(open('../frwiki.json'))
    frarticles = frindex['articles']
    endict = {}
    for article in enarticles:
        if 'wc' in article:
            endict[article['title']] = article['wc']

    for frarticle in frarticles:
        enarticle = frarticle['translation']
        if enarticle in endict:
            score = numcompare.main('../frwiki/' + frarticle['title'] + '.txt', '../enwiki/' + enarticle + '.txt')
            print("\t".join((frarticle['title'].encode("utf-8"), enarticle.encode("utf-8"), str(score))))
    return 0

if __name__ == "__main__":
    sys.exit(main())
